"""backend URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/4.1/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path,include
from django.views.static import serve
from rest_framework_nested import routers
from rest_framework.documentation import include_docs_urls
from user.views import UserViewSet
from casting.views import *
from weld.views import *
# Routers provide an easy way of automatically determining the URL conf.
router = routers.DefaultRouter()
router.register("user",UserViewSet,basename="user")
router.register("casting",CastingViewSet,basename="casting")
router.register('weldtask',WeldTaskViewSet,basename='weldtask')

weld_video_router = routers.NestedSimpleRouter(router,"weldtask",lookup="weldtask")
weld_video_router.register("video",WeldVideoViewSet,basename="video")
weld_defect_router=routers.NestedSimpleRouter(weld_video_router,"video",lookup="video")
weld_defect_router.register("viddefect",WeldDefectViewSet,basename="viddefect")

cast_film_router=routers.NestedSimpleRouter(router,"casting",lookup="casting")
cast_film_router.register("film",CastingFilmViewSet,basename="film")
cast_defect_router=routers.NestedSimpleRouter(cast_film_router,"film",lookup="film")
cast_defect_router.register("defect",CastingDefectViewSet,basename="defect")
urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include(router.urls)),
    path('', include(cast_film_router.urls)),
    path('', include(cast_defect_router.urls)),
    path('', include(weld_video_router.urls)),
    path('', include(weld_defect_router.urls)),
    path('api-auth/', include('rest_framework.urls')),
    path('docs/',include_docs_urls(title="API接口文档")),
    path('data/<path:path>', serve, {'document_root': 'data'}), # 数据显示配置
]
